package kr.saeildamil.androidstudy_second.fragment;

import kr.saeildamil.androidstudy_second.R;
import kr.saeildamil.androidstudy_second.fragment.common.CounterFragment03;
import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

public class FragmentArgument extends Activity {
	EditText mStartNum;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch20_fragmentargument);
		
		mStartNum = (EditText)findViewById(R.id.ch20_fragmentargument_startnum);
		
		getFragmentManager().beginTransaction().add(R.id.ch20_fragmentargument_frame,new CounterFragment03().newInstance(1),"counter").commit();
	}
	public void mOnClick(View v){
		switch(v.getId()){
		case R.id.ch20_fragmentargument_btnadd:
			FragmentManager fm = getFragmentManager();
			FragmentTransaction tr = fm.beginTransaction();
			int start = Integer.parseInt(mStartNum.getText().toString());
			CounterFragment03 cf = CounterFragment03.newInstance(start);
			//tr.add(R.id.ch20_fragmentargument_frame, cf, "counter");
			tr.replace(R.id.ch20_fragmentargument_frame, cf, "counter");
			tr.addToBackStack(null);
			tr.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
			tr.commit();
			break;
		}
	}
	
}
